<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>yum局域网软件源搭建 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>yum局域网软件源搭建</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux/">Linux</a>
			</span>
		
	</div>

	

	
		<h2 id="1-搭建apache服务器或ftp服务器"><a href="#1-搭建apache服务器或ftp服务器" class="headerlink" title="1.搭建apache服务器或ftp服务器"></a>1.搭建apache服务器或ftp服务器</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;yum安装或二进制安装</p>
<h2 id="2、准备RPM包"><a href="#2、准备RPM包" class="headerlink" title="2、准备RPM包"></a>2、准备RPM包</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;把CentOS的DVD1和DVD2.iso都下载下来，把DVD1.iso里的所有内容解压出来，放到/var/www/html/centos-6目录下，然后把DVD2.iso解压出来的Packages目录下的rpm包复制到/var/html/centos-6/Packages目录下，这样/var/html/centos-6/Packages里面就有了6000多个rpm包。</p>
<h2 id="3、创建yum仓库"><a href="#3、创建yum仓库" class="headerlink" title="3、创建yum仓库"></a>3、创建yum仓库</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;准备createrepo：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum -y install createrepo</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;创建repository：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">createrepo /var/www/html/centos-6/</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;创建完成之后，会在/var/www/html/centos-6/repodata下生成一些文件。</p>
<h2 id="4、使用软件源"><a href="#4、使用软件源" class="headerlink" title="4、使用软件源"></a>4、使用软件源</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在其他centos机器上试试软件源能不能用。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;首先修改机器上软件源配置文件：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># cd /etc/yum.repos.d/</span></div><div class="line"><span class="comment"># mkdir bk</span></div><div class="line"><span class="comment"># mv *.repo bk/</span></div><div class="line"><span class="comment"># cp bk/CentOS-Base.repo ./</span></div><div class="line"><span class="comment"># vi CentOS-Base.repo</span></div><div class="line">CentOS-Base.repo文件修改之后如下：</div><div class="line">[base]</div><div class="line">name=CentOS-<span class="variable">$releasever</span> - Base</div><div class="line">baseurl=http://*.*.*.*/centos-6/</div><div class="line">gpgcheck=1(改成0下面那行就不用设置了)</div><div class="line">gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6</div><div class="line">enabled=1</div><div class="line"><span class="comment">#released updates</span></div><div class="line"><span class="comment">#[updates]</span></div><div class="line"><span class="comment">#name=CentOS-$releasever - Updates</span></div><div class="line"><span class="comment">#baseurl=http:///*.*.*.*/centos-6/</span></div><div class="line"><span class="comment">#gpgcheck=1</span></div><div class="line"><span class="comment">#gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6</span></div><div class="line"><span class="comment">#enabled = 1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存之后，就可以使用局域网的软件源了：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="comment"># yum update</span></div></pre></td></tr></table></figure>
	

	
		<span class="different-posts"><a href="/2017/10/12/1. Linux 基础/39.yum局域网软件源搭建/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
